﻿document.write('<script src="script/jquery.js"></script>');
var is_collapsed = false;
function ToggleCollapse()
{
    if (is_collapsed) { 
        document.getElementById("nav").style.display = '';
        document.getElementById("collapse").style.display = "";
        document.getElementById("expand").style.display = 'none';
        is_collapsed = false;
    } else {
        document.getElementById("nav").style.display = 'none';
        document.getElementById("collapse").style.display = "none";
        document.getElementById("expand").style.display = '';
        is_collapsed = true;
    }
}

var channel_collapsed = false;
function channelCollapse()
{
    if (channel_collapsed) { 
        document.getElementById("channel-container").style.display = '';
        document.getElementById("channel-down").style.display = "";
        document.getElementById("channel-right").style.display = 'none';
        channel_collapsed = false;
    } else {
        document.getElementById("channel-container").style.display = 'none';
        document.getElementById("channel-down").style.display = "none";
        document.getElementById("channel-right").style.display = '';
        channel_collapsed = true;
    }
}
var provider_collapsed = false;
function providerCollapse()

{

    if (provider_collapsed) { 

        document.getElementById("provider-container").style.display = '';

        document.getElementById("provider-down").style.display = "";

        document.getElementById("provider-right").style.display = 'none';

        provider_collapsed = false;

    } else {

        document.getElementById("provider-container").style.display = 'none';

        document.getElementById("provider-down").style.display = "none";

        document.getElementById("provider-right").style.display = '';

        provider_collapsed = true;

    }

}



var publisher_collapsed = false;

function publisherCollapse()

{

    if (publisher_collapsed) { 

        document.getElementById("publisher-container").style.display = '';

        document.getElementById("publisher-down").style.display = "";

        document.getElementById("publisher-right").style.display = 'none';

        provider_collapsed = false;

    } else {

        document.getElementById("publisher-container").style.display = 'none';

        document.getElementById("publisher-down").style.display = "none";

        document.getElementById("publisher-right").style.display = '';

        provider_collapsed = true;

    }

}



var reader_collapsed = false;

function readerCollapse()

{

    if (reader_collapsed) { 

        document.getElementById("reader-container").style.display = '';

        document.getElementById("reader-down").style.display = "";

        document.getElementById("reader-right").style.display = 'none';

        reader_collapsed = false;

    } else {

        document.getElementById("reader-container").style.display = 'none';

        document.getElementById("reader-down").style.display = "none";

        document.getElementById("reader-right").style.display = '';

        reader_collapsed = true;

    }

}



function showAddChannel()
{
	document.getElementById("main-right-box").src = "admin_add_channel.php";	
}



function showAddProvider()
{
	document.getElementById("main-right-box").src = "admin_add_provider.php";
}
function showAddPublisher()

{

	document.getElementById("main-right-box").src = "admin_add_publisher.php";	

}



function showAddReader()

{

	document.getElementById("main-right-box").src = "admin_add_reader.php";	

}



function sendTo(url,param)

{ 

	var req = false; 

	

	document.getElementById("status").style.display = 'block';

	document.getElementById("status").innerHTML=".......";

	

	if (window.XMLHttpRequest) { // Mozilla, Safari,...

         req = new XMLHttpRequest();

         if (req.overrideMimeType) {

         	// set type accordingly to anticipated content type

            //req.overrideMimeType('text/xml');

            req.overrideMimeType('text/html');

         }

      } else if (window.ActiveXObject) { // IE

         try {

            req = new ActiveXObject("Msxml2.XMLHTTP");

         } catch (e) {

            try {

               req = new ActiveXObject("Microsoft.XMLHTTP");

            } catch (e) {}

         }

      }

      if (!req) {

         alert('Cannot create XMLHTTP instance');

         return false;

      }



	req.onreadystatechange = function()

	{ 

		document.getElementById("status").innerHTML="Wait server...";

		if(req.readyState == 4)

		{

			if(req.status == 200)

			{

				document.getElementById("status").innerHTML=req.responseText;	

			}	

			else	

			{

				document.getElementById("status").innerHTML="Error: returned status code " + req.status + " " + req.statusText;

			}	

		} 

	}; 

	req.open("POST", url, true); 

	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 

	req.setRequestHeader("Content-length", param.length);

	req.setRequestHeader("Connection", "close");

	req.send(param);

} 



function searchChannel()
{
	var t = document.getElementById("channel-title").value;
	var l = document.getElementById("channel-link").value;
	var r = document.getElementById("channel-rank").value;
	document.getElementById("main-right-box").src = "search_channel.php?title="+t+"&link="+l+"&rank="+r;
}



function searchProvider()
{
	var u = document.getElementById("provider-username").value;
	var f = document.getElementById("provider-fname").value;
	var l = document.getElementById("provider-lname").value;
	var c = document.getElementById("provider-company").value;
	document.getElementById("main-right-box").src = "search_provider.php?username="+u+"&fname="+f+"&lname="+l+"&company="+c;
}



function searchPublisher()
{
	var u = document.getElementById("publisher-username").value;
	var f = document.getElementById("publisher-fname").value;
	var l = document.getElementById("publisher-lname").value;
	var c = document.getElementById("publisher-company").value;
	document.getElementById("main-right-box").src = "search_publisher.php?username="+u+"&fname="+f+"&lname="+l+"&company="+c;
}



function searchReader()
{
	var u = document.getElementById("reader-username").value;
	var f = document.getElementById("reader-fname").value;
	var l = document.getElementById("reader-lname").value;
	var c = document.getElementById("reader-company").value;
	document.getElementById("main-right-box").src = "search_reader.php?username="+u+"&fname="+f+"&lname="+l+"&company="+c;
}



function viewFeed(id,title,page,perpage){

		document.getElementById("main-right-box").src = "reader_read_items.php?id="+id+"&title="+title+"&page="+page+"&perpage="+perpage;

}

function nextpage (channelid, key,page,perpage){

	alert(page);

	searchItem(channelid, key,parseInt(page)+1,perpage);

}

function prevpage (channelid, key,page,perpage){

	searchItem(c